  function parseQueryFromUrl () {
	var queryParamName = "q";
	var search = window.location.search.substr(1);
	var parts = search.split('&');
	for (var i = 0; i < parts.length; i++) {
	  var keyvaluepair = parts[i].split('=');
	  if (decodeURIComponent(keyvaluepair[0]) == queryParamName) {
		return decodeURIComponent(keyvaluepair[1].replace(/\+/g, ' '));
	  }
	}
	return '';
  }

  google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
  google.setOnLoadCallback(function() {
	var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
	  '002652159583975207123:WMX-1927619761', customSearchOptions);
	customSearchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
	var options = new google.search.DrawOptions();
	options.setAutoComplete(true);
	options.enableSearchResultsOnly(); 
	customSearchControl.draw('cse', options);
	var queryFromUrl = parseQueryFromUrl();
	if (queryFromUrl) {
	  customSearchControl.execute(queryFromUrl);
	}
  }, true);
